<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\DB;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Post>
 */
class PostFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition()
    {
        $paras = fake()->paragraphs(fake()->numberBetween(5,15));
        $content = "";
        foreach($paras as $p){
            $content .= "<p>" . $p . "</p>";
        }
        $max_user_id = DB::table("users")->max('id');
        $title = fake()->sentence(fake()->numberBetween(3,9));
        $title = str_replace(".","",$title);
        return [
            'title' => $title,
            'content' => $content,
            'user_id' => fake()->numberBetween(1,$max_user_id),
        ];
    }
}
